import { 
  CustomFileSize, 
  NumberItem, 
  CustomCheckBox, 
  CustomRadio, 
  CustomSelect, 
  CustomInput, 
  CustomSwitch, 
  CustomRangePicker, 
  CustomMemberSelect,
  CustomSelectFileOrFolder
} from './preview/web/components/AdvancedSearch/controlTypeFormItem'
export const componentObject: { [key: string]: JSX.Element } = {
  edoc2Textbox: <CustomInput />,
  edoc2Number: <NumberItem />,
  edoc2FileSize: <CustomFileSize />,
  edoc2Switch: <CustomSwitch />,
  edoc2Date: <CustomRangePicker />,
  edoc2TextArea: <CustomInput textarea />,
  edoc2RichText: <CustomInput textarea />,
  edoc2SelectFolder: <CustomSelectFileOrFolder mode='SelectFolder' />,
  edoc2SelectMember: <CustomMemberSelect config={{ tabs: ['user'] }} />,
}
export const filterkeys = [
  'filename',
  'foldername',
  'fileextname',
  'filepath', 
  'folderpath', 
  'filecreateoperator', 
  'filemodifyoperator', 
  'filecreatetime',
  'filemodifytime',

  'foldercreateoperator', 
  'foldermodifyoperator', 
  'foldercreatetime',
  'foldermodifytime',
]
export const getComponent = (metaData: any) => {
  if (metaData.controlType) {
    const { controlType, mode } = metaData
    if (controlType == 'edoc2Selectbox') {
      if (mode == 'singleSelectbox' || mode == 'multipleSelectbox') {
        return <CustomSelect mode={mode} />
      } else if (mode == 'single') {
        return <CustomRadio style={{ width: '100%' }} />
      } else if (mode == 'multiple') {
        return <CustomCheckBox style={{ width: '100%' }} />
      }
    } else {
      return componentObject[controlType]
    }
  } else {
    return <CustomInput />
  }
}